package com.fwtai.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;

import java.util.HashMap;

/**
 * 系统用户访问数据库
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2021-07-21 17:49:27
 * @QQ号码 444141300
 * @Email service@yinlz.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class UserAccountDao{

  private final DaoHandle dao;

  public UserAccountDao(final DaoHandle dao){
    this.dao = dao;
  }

  public int add(final PageFormData pageFormData){
    return dao.execute("user_account.add",pageFormData);
  }

  public String queryExistById(final String kid){
    return dao.queryForString("user_account.queryExistById",kid);
  }

  public int edit(final PageFormData pageFormData){
    return dao.execute("user_account.edit",pageFormData);
  }

  public HashMap<String, Object> queryById(final String kid){
    return dao.queryForHashMap("user_account.queryById",kid);
  }

  public HashMap<String,Object> listData(final PageFormData pageFormData){
    return dao.queryForPage(pageFormData,"user_account.listData","user_account.listTotal");
  }

  public int editEnabled(final PageFormData formData){
    return dao.execute("sys_user.editEnabled",formData);
  }

  public Integer queryLogin(final Long userId){
    return dao.queryForInteger("user_account.queryLogin",userId);
  }

  public int editCategory(final Long kid,final Integer category){
    final PageFormData formData = new PageFormData();
    formData.put("kid",kid);
    formData.put("category",category);
    return dao.execute("user_account.editCategory",formData);
  }
}